package com.springboot.cloud.demos.ribbon.rest;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.ProfitRecordForm;
import com.springboot.cloud.demos.entity.form.ProfitRecordQueryForm;
import com.springboot.cloud.demos.entity.po.ProfitRecord;
import com.springboot.cloud.demos.ribbon.service.ProfitRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ProfitRecordController {

    @Autowired
    private ProfitRecordService profitRecordService;

    @PostMapping("/profitRecord/list")
    public Result<Page> list(@RequestBody ProfitRecordQueryForm param) {
        return profitRecordService.list(param);
    }

    @GetMapping("/profitRecord/{id}")
    public Result<ProfitRecord>  get(@PathVariable(value = "id") String id) {
        return profitRecordService.get(id);
    }

    @PostMapping("/profitRecord")
    public Result<ProfitRecord>  add(@RequestBody ProfitRecordForm profitRecordForm) {
        return profitRecordService.save(profitRecordForm);
    }

    @PutMapping(value = "/profitRecord")
    public Result update(@RequestBody ProfitRecordForm profitRecordForm) {
        return profitRecordService.update(profitRecordForm);
    }
}
